<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/template.xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="title">
        HelpDeskRu:AdminZone
    </ui:define>

    <ui:define name="top_menu">
        <ui:include src="/admin/main_menu.xhtml"/>
    </ui:define>
    
    <ui:define name="content">
        
        <h:form id="form">

            <p:dataTable value="#{serviceObjectController.listAllServiceObject}" var="item" 
                         emptyMessage="" rowKey="#{item.id}" editable="true">
                
                <f:facet name="header">
                    
                    <h:outputText value="#{prop['admin.service_objects.header']}"/>
                    <br/>
                    <div align="left">
                        <p:commandButton value="#{prop['admin.service_objects.addNewServiceObject']}"
                                         actionListener="#{serviceObjectController.addNewServiceObject}"
                                         update="@form"
                                         icon="ui-icon-plus"/>
                    </div>
                </f:facet>


                <p:column headerText="Id">
                    <h:outputText value="#{item.id}" />
                </p:column>

                
                
                <p:column headerText="#{prop['admin.service_objects.dataTableheaderTextName']}">

                    <p:cellEditor>

                        <f:facet name="output">
                            <h:outputText value="#{item.name}" />
                        </f:facet>

                        <f:facet name="input">
                            <h:inputText value="#{item.name}" size="15"/>
                        </f:facet>

                    </p:cellEditor>

                </p:column>
                
                
                <p:column headerText="#{prop['admin.service_objects.dataTableheaderTextDescription']}">

                    <p:cellEditor>

                        <f:facet name="output">
                            <h:outputText value="#{item.description}" />
                        </f:facet>

                        <f:facet name="input">
                            <h:inputText value="#{item.description}" size="15"/>
                        </f:facet>

                    </p:cellEditor>

                </p:column>


                <p:column headerText="#{prop['admin.service_objects.dataTableheaderTextAddress']}">

                    <p:cellEditor>

                        <f:facet name="output">
                            <h:outputText value="#{item.address}" />
                        </f:facet>

                        <f:facet name="input">
                            <h:inputText value="#{item.address}" size="15"/>
                        </f:facet>

                    </p:cellEditor>

                </p:column>



                <p:column headerText="#{prop['admin.service_objects.dataTableheaderTextMaintenanceStatus']}">

                    <p:cellEditor>

                        <f:facet name="output">
                            <h:outputText value="#{item.maintenanceStatus}" />
                        </f:facet>

                        <f:facet name="input">
                            <h:inputText value="#{item.maintenanceStatus}" size="15"/>
                        </f:facet>

                    </p:cellEditor>

                </p:column>




                
                <p:column headerText="#{prop['admin.service_objects.dataTableheaderTextOrganization']}">
                    <p:cellEditor>

                        <f:facet name="output">
                            <h:outputText value="#{item.organization.toString()}" />
                        </f:facet>

                        <f:facet name="input">
                            
                            <h:selectOneMenu value="#{item.organization}">
                                <f:selectItems value="#{organizationController.selectItemListOrganization}"/>
                            </h:selectOneMenu>

                        </f:facet>

                    </p:cellEditor>
                    
                </p:column>
                
                
                <p:column>
                    <p:rowEditor />
                </p:column>


                <p:column> 
                    
                                    
                    <p:commandLink  value="#{prop['admin.service_objects.deleteServiceObject']}"
                                    update=":deleteServiceObjectForm:deleteServiceObjectPanel"
                                    oncomplete="deleteServiceObjectConfirmDialog.show()">
                        <f:setPropertyActionListener target="#{serviceObjectController.currentServiceObject}" 
                                                     value="#{item}"/>
                    </p:commandLink>
                </p:column>


                <f:facet name="footer">
                    <div align="left">
                        <p:commandButton value="#{prop['admin.service_objects.saveAll']}" actionListener="#{serviceObjectController.saveAll}"
                                         update="@form"
                                         icon="ui-icon-disk"/>
                        
                    </div>
                </f:facet>
                
            </p:dataTable>            
            
            
            
            
            
            
            
            
            
            
            
        </h:form>

        
        

        <h:form id="deleteServiceObjectForm">
        
            <p:outputPanel id="deleteServiceObjectPanel">
                
                <p:confirmDialog message="#{prop['admin.service_objects.deleteServiceObjectPanel.message']} #{serviceObjectController.currentServiceObject}?"
                                header="#{prop['admin.service_objects.deleteServiceObjectPanel.header']}" severity="alert"
                                widgetVar="deleteServiceObjectConfirmDialog">

                    <p:commandButton value="#{prop['admin.yes']}"
                                     actionListener="#{serviceObjectController.deleteServiceObject}"
                                     action="/admin/service_objects"
                                     update=":form"
                                     oncomplete="deleteServiceObjectConfirmDialog.hide()"/>

                    <p:commandButton value="#{prop['admin.no']}"
                                     onclick="deleteServiceObjectConfirmDialog.hide()"
                                     type="button" />

                </p:confirmDialog>

            </p:outputPanel>
            
        </h:form>
        
        
        
    </ui:define>
    
</ui:composition>